using System;
using ContactPrinter.Model.Interfaces;

namespace ContactPrinter.Model
{
    public class CategorizedAttributeBase : ICategorizedAttribute
    {
        public static Category FromRelString(string rel)
        {
            Category result = Category.None;
            if (!string.IsNullOrEmpty(rel))
            {
                var splittedRel = rel.Split('#');
                if (splittedRel.Length == 2)
                {
                    Enum.TryParse(splittedRel[1], true, out result);
                }
            }
            return result;
        }

        #region Implementation of ICategorizedAttribute

        public Category Type { get; set; }

        #endregion
    }
}